/**
 * @author WangXinLei
 * @date 2014-11-06
 */
package com.chnbst.bstyun.eos;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.chnbst.bstyun.service.CashflowService;
import com.chnbst.bstyun.service.PaymentService;

@Component
public class CreateNum {
	
	private final static Logger logger = LoggerFactory.getLogger(CreateNum.class);
	
	@Autowired
	private CashflowService cashflowService;
	@Autowired
	private PaymentService paymentService;
	
	public String createCashflowNum(String dealType) {
		
		//根据交易类型获取到该交易类型下最大的流水号
		String bigNum = cashflowService.selectBigNumByDealType(dealType);
		if(bigNum == null){
			bigNum = dealType + "000001";
		}else{
			bigNum = String.valueOf(Integer.valueOf(bigNum) + 1);
		}
		
		return bigNum;
	}
	
	public String createPaymentNum(String dealType) {
		
		//根据交易类型获取到该交易类型下最大的流水号
		String bigNum = paymentService.selectBigNumByDealType(dealType);
		if(bigNum == null){
			bigNum = dealType + "000001";
		}else{
			bigNum = String.valueOf(Integer.valueOf(bigNum) + 1);
		}
		
		return bigNum;
	}
	
	
}
